<?php
//The next comment block is for PHPDocumentor
/**
 * Conference Registration - Registration for conferences
 * 
 * Admin menu option:
 * Export data in various formats
 * 
 * @author Kevin van Haaren (kevin@vanhaaren.net)
 * @copyright 2006 Kevin van Haaren, US
 * @package CONFREG
 * @subpackage Admin_Function
 * 
 */

/**
* Do all the declarations etc needed by an admin page
*/
include_once "adminheader.inc";

//Display the admin menu
xoops_module_admin_menu(3,_AM_CONFREG_ADMENU2);

/**
* To use this as a template you need to write code to display
* whatever it is you want displaying between here...
*/

// form for export to csv buttons
echo '<form action="adminexport.php" method="post">';
echo '<input type="submit" name="submit" value="Export Label Data" />&nbsp;&nbsp;';
echo '<input type="submit" name="submit" value="Export All Data" /><br />';
echo '</form>';

$dHdl = $xoopsDB->query('SELECT p.userid, p.first_name, p.last_name, p.tmc_num, p.days_attending' .
						', g.company, g.total_cost, g.paid' .
                        ' FROM ' . $xoopsDB->prefix('confreg_people') . ' p' .
 						' JOIN ' . $xoopsDB->prefix('confreg_groups') . ' g' .
 						' ON p.groupid = g.groupid' .
                        ' WHERE (p.confid = 1)');

echo '<br /><br /><table>';
echo '<tr><th>First Name</th><th>Last Name</th><th>Company</th><th>TMC Num</th><th>Days</th><th>Workshop 1</th><th>Workshop 2</th><th>Workshop 3</th><th>Paid</th></tr>';
while ($data = $xoopsDB->fetchArray($dHdl)) {
	echo '<tr><td>' . $data['first_name'] . '</td><td>'
	                . $data['last_name'] . '</td><td>'
	                . $data['company'] . '</td><td>'
	                . $data['tmc_num'] . '</td><td>'
	                . $data['days_attending'] . '</td>';

  	$wHdl = $xoopsDB->query('SELECT w.title, w.start_time' .
  							' FROM ' . $xoopsDB->prefix('confreg_workshop_res') . ' r' .
  							' JOIN ' . $xoopsDB->prefix('confreg_workshops') . ' w' .
  							' ON r.workshopid = w.workshopid' .
  							' WHERE (r.userid = ' . $data['userid'] . ') ' .
  							' ORDER BY w.start_time' );




 	$cells = array('&nbsp;','&nbsp;','&nbsp;');
 	$cptr = 0;
 	while ($shop = $xoopsDB->fetchArray($wHdl)) {
 		$cells[$cptr++] = $shop['title'];
 	}
 
 	for ($i=0;$i<3;$i++) {
 		echo '<td>' . $cells[$i] . '</td>';
 	}

	echo '<td>';
	echo ($data['total_cost'] == $data['paid']) ? 'Yes' : 'No';
	echo '</td>';

	echo '</tr>';

}
echo '</table>';


/**
* and here.
*/
//And put footer in
xoops_cp_footer();

/*
 * This file was generated by XBS ModGen, (c) 2006 A Kitson, UK. See http://xoobs.net
 * ModGen is a Module Code Generator for the Xoops CMS.  See http://xoops.org
 */
?>